<template>
  <div class="alert-body" v-if="dialogVisible">
    <div class="alert-box">
      <div class="alert-box-header">
        <span>学生发展水平</span>
        <span class="iconfont iconguanbi" @click="closeModle"></span>
      </div>
      <div class="alert-box-body">
        <div class="teacher-content">
          <div class="corner-data" v-if="cornerList.length">
            <div class="corner-data-list" v-for="item in cornerList" :key="item.id">
              <div class="corner-data-list-top-t">
                <div class="corner-data-list-img">
                  <el-image :src="item.pic">
                  </el-image>
                </div>
                <div class="corner-data-list-right">
                  <div class="corner-data-list-right-line">
                    <div class="corner-data-list-right-line-l">
                      <span>名称：</span>{{ item.name }}
                    </div>
                    <div class="corner-data-list-right-line-l">
                      <span>达标时长：</span>{{ item.time }}分钟
                    </div>
                    <div class="corner-data-list-right-line-l">
                      <span>创建时间：</span>{{ item.create_time }}
                    </div>
                  </div>
                  <div class="corner-data-list-right-line">
                    <div class="corner-data-list-right-line-l">
                      <span>预约人次：</span><i>{{ item.apply_number || 0 }}</i>
                    </div>
                    <div class="corner-data-list-right-line-l">
                      <span>参与人次：</span><i>{{ item.in_number || 0 }}</i>
                    </div>
                    <div class="corner-data-list-right-line-l">
                      <span>达标人次：</span><i>{{ item.complete_number || 0 }}</i>
                    </div>
                  </div>
                </div>
              </div>
              <div class="corner-data-list-top-b">
                <div class="corner-data-list-right-line-l" v-for="className in item.section"
                     @click="showCorner(item,className)">
                  <i>{{ className.number }}</i><span>{{ className.section_name }}评价人次</span>
                </div>
              </div>
            </div>
          </div>
          <div v-else class="cornernot">
            <i class="iconfont iconwodewenzhang"></i>
            暂无区角统计记录
          </div>
        </div>
      </div>
      <div class="alert-box-footer">
        <span @click="closeModle">返回</span>
        <span @click="InitFn()">刷新当前记录</span>
      </div>
    </div>
    <popupCornerList :visible.sync="showPopup" :cornerId="cornerId" :sectionId="sectionId" :cornerName="cornerName"
                     :sectionName="sectionName"></popupCornerList>
  </div>
</template>
<script>
import {cornerBrandIndex} from "@/api/admin/corner";
import popupCornerList from "@/fullscreen/components/popupCornerList";

export default {
  name: "foodData",
  props: ['visible', 'dataOption'],
  components: {popupCornerList},
  data() {
    return {
      typeData: 'food_check',
      foodCodeVisible: false,
      dialogVisible: false,
      cornerList: [],
      showPopup: false,
      cornerId: 0,
      sectionId: '',
      cornerName: '',
      sectionName: ''
    };
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.InitFn()
        // honorDetail({name: this.dataOption}).then(res=>{
        //   console.log('res++++', res)
        //   this.teacherList = res.list
        // })
      } else {
        this.teacherList = []
      }
    }
  },
  created() {
  },
  mounted() {

  },
  methods: {
    showCorner(item, className) {
      if(className.number){
        this.cornerName = item.name
        this.cornerId = item.id
        this.sectionId = className.id
        this.sectionName = className.section_name
        this.showPopup = true
      }else{
        this.$message.warning('没有可查看的记录');
      }
    },
    // 初始化
    InitFn() {
      const loading = this.$loading({
        lock: true,
        text: '加载中…',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });

      cornerBrandIndex().then(res => {
        console.log('res:', res)
        for (let item of res.list) {
          item.create_time = item.create_time.split(' ')[0]
        }
        this.cornerList = res.list
        setTimeout(() => {
          loading.close();
        }, 1000);
      })
    },
    closeModle() {
      this.$emit('update:visible', false)
      this.dialogVisible = false
    },
    confirmFn() {
      this.showTime = false
    },
  }
};
</script>
<style scoped>
.alert-body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-box {
  width: 85%;
  height: 85%;
  border: 1px solid #005da6;
  background: rgba(13, 17, 44, .8);
  display: flex;
  flex-direction: column;
  border-radius: 10px;
}

.alert-box-header {
  height: 60px;
  display: flex;
  color: #beebfe;
  font-size: 26px;
  padding: 0 20px;
  line-height: 60px;
}

.alert-box-header .iconfont {
  font-size: 26px;
  cursor: pointer;
  margin-left: 20px;
  padding: 0 10px;
}

.alert-box-header span:first-child {
  flex: 1;
}

.alert-box-footer {
  height: 80px;
}

.alert-box-body {
  flex: 1;
  padding: 0 10px;
  overflow-y: auto;
}


.alert-box-list-in i {
  color: #02d5ff;
  font-style: normal;
  font-size: 20px;
  font-weight: bold;
}

.alert-box-list-in em {
  font-style: normal;
}

.alert-box-footer {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-box-footer span {
  display: block;
  border: 1px solid #beebfe;
  color: #beebfe;
  width: 180px;
  height: 50px;
  line-height: 48px;
  font-size: 20px;
  border-radius: 3px;
  cursor: pointer;
}

.alert-box-footer span:first-child {
  margin-right: 20px;
}

.alert-box-footer span:hover {
  background: rgba(0, 73, 85, 0.6);

}

.corner-data {
  overflow: hidden;
  background: rgba(255, 255, 255, .2);
  padding: 10px;
}

.corner-data-list {
  float: left;
  border: 1px solid #ddd;
  box-shadow: 0 2px 2px #ddd;
  border-radius: 5px;
  margin-right: 10px;
  margin-bottom: 10px;
  display: flex;
  padding: 10px 5px;
  cursor: pointer;
  flex-direction: column;
  background: #fff;
}

.corner-data-list:hover {
  border: 1px solid rgba(183, 211, 241, 0.9);
  background: rgba(183, 211, 241, 0.9);
  box-shadow: 0 2px 2px rgba(183, 211, 241, 0.9);
}

.corner-data-list-img {
  margin-right: 5px;
}

.corner-data-list-top-t {
  display: flex;
}

.corner-data-list-top-b {
  display: flex;
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.corner-data-list-top-b .corner-data-list-right-line-l {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #eee;
}

.corner-data-list-top-b .corner-data-list-right-line-l:last-child {
  border: none;
}

.corner-data-list-top-b .corner-data-list-right-line-l i {
  font-size: 18px;
  color: #006dcd;
  font-weight: bold;
  font-style: normal;
}


.corner-data-list-right {
  display: flex;
}

.corner-data-list-right-line:first-child {
  width: 160px;
}

.corner-data-list-right-line {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.corner-data-list-right-line:nth-child(2) {
  width: 110px;
}

.corner-data-list-right-line:nth-child(3) {
  width: 130px;
}

.corner-data-list-right-line-l {
  display: flex;
  align-items: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.corner-data-list-right .corner-data-list-right-line-l span {
  color: #999;
  font-size: 13px;
}

.corner-data-list-right .corner-data-list-right-line-l i {
  font-style: normal;
}

.corner-data-list-img .el-image {
  width: 100px;
  height: 100px;
}
</style>
